From: Yehuda Katz Date: Fri, 30 May 2014 01:11:27 +0000 (-0700) Subject: Improve errors slightly X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~1033 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=30cc28333dd3ce5f62409e6a14ae2641c512f032;p=cargo.git Improve errors slightly --- diff --git a/src/cargo/sources/git.rs b/src/cargo/sources/git.rs index 740b934d1..f2bc69fdc 100644 --- a/src/cargo/sources/git.rs +++ b/src/cargo/sources/git.rs @@ -317,12 +317,12 @@ fn git(path: &Path, verbose: bool, str: &str) -> ProcessBuilder { fn git_inherit(path: &Path, verbose: bool, str: String) -> CargoResult<()> { git(path, verbose, str.as_slice()).exec().map_err(|err| - human_error(format!("Couldn't execute `git {}`: {}", str, err), None::<&str>, err)) + human_error(format!("Executing `git {}` failed: {}", str, err), None::<&str>, err)) } fn git_output(path: &Path, verbose: bool, str: String) -> CargoResult { let output = try!(git(path, verbose, str.as_slice()).exec_with_output().map_err(|err| - human_error(format!("Couldn't execute `git {}`", str), None::<&str>, err))); + human_error(format!("Executing `git {}` failed", str), None::<&str>, err))); Ok(to_str(output.output.as_slice()).as_slice().trim_right().to_str()) } diff --git a/src/cargo/util/result.rs b/src/cargo/util/result.rs index 8ce1b72fe..26b235b88 100644 --- a/src/cargo/util/result.rs +++ b/src/cargo/util/result.rs @@ -69,7 +69,7 @@ pub fn toml_error(desc: &'static str, error: toml::Error) -> CargoError { } } -#[deriving(Show,Clone)] +#[deriving(Eq,Clone)] pub struct CargoError { pub kind: CargoErrorKind, desc: CargoErrorDescription, @@ -77,7 +77,16 @@ pub struct CargoError { cause: Option> } -#[deriving(Show,Clone)] +impl Show for CargoError { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + match self.desc { + StaticDescription(string) => write!(f, "{}", string), + BoxedDescription(ref string) => write!(f, "{}", string) + } + } +} + +#[deriving(Eq,Show,Clone)] enum CargoErrorDescription { StaticDescription(&'static str), BoxedDescription(String) @@ -118,6 +127,7 @@ impl CargoError { } } +#[deriving(Eq)] pub enum CargoErrorKind { HumanReadableError, InternalError,